package com.shareach.util;  

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;

import com.benayn.ustyle.logger.Loggers;


/** 
 * create time：2013-1-25 上午11:50:55 
 * @author retryu 
 * @since JDK 1.6
 * @version 1.0  
 * description： 
 */
public class ExcelParseState {
	private static final Log log = Loggers.from(ExcelParseState.class);
	
	public class  State{
		public  String name;
		public int  total;
		public int  current;
		public  int  success;
		@Override
		public String toString() {
			return "State [name=" + name + ", total=" + total + ", current="
					+ current + ", success=" + success + "]";
		}
		
		
	}
	
	
	public List<State>  states;
	
	
	public ExcelParseState() {
		states=new  ArrayList<ExcelParseState.State>();
	}
	
	
	public synchronized State addState(){
		State  state=new  State();
		states.add(state);
		return  state;
	}
	public synchronized  State  getState(int  index){
		if(index>states.size()-1){
			return null;
		}
		 
		return  states.get(index);
	}
	
	
	public synchronized  void  updateProgress(int  index,int current ){
		State  state=states.get(index);
		state.current=current;
	}
	public  void  increaseProgress(int  index){
		State  state=states.get(index);
		state.current++;
	}
	
	public  void  increaseSuccess(int index){
		State  state=states.get(index);
		state.success++;
	}
	
	
	
	public int total;
	public int current;
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getCurrent() {
		return current;
	}
	public void setCurrent(int current) {
		this.current = current;
	}
	
	
	public  void  PrintState(){
		for(State  state:states){
			log.info("state:"+state);
		}
	}
	

}
  
